<?php

namespace app\models\config;
use Yii;
use app\models\BaseForm;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of SiteForm
 *
 * @author shuai
 */
class activityForm extends BaseForm {

    public static function model($className = __CLASS__) {
        return parent::model($className);
    }

    protected $houzhui = 'activity';
   /* 
    public $activity_Underway; ///表示活动是否继续
    public $activity_EndTime; //活动结束的时间 
    */
    public $activity_secretKey;
    public $activity_secretId;
    public $activity_businessId;
    
    public $activity_MsgAppkey;
    public $activity_MsgAppsecret;
    
    /**
     * 给用户发送的信息
    */
    public $activity_userMsg;
    
    /**
     * 是否显示预约按钮
    */
    public $activity_nextIsTrue;
    /**
     * 预约的图片
    */
    public $activity_ProductPic;
    public $activity_nextProductPic;
    /**
     * @inheritdoc
     */
    public function rules() {
        return [
            ////  ['verifyCode', 'captcha','captchaAction'=>'/admin/site/captcha'],
            [[//'activity_Underway', 'activity_EndTime',
                'activity_secretKey',
                'activity_secretId',
                'activity_businessId',
                
                'activity_MsgAppkey',
                'activity_MsgAppsecret',
                'activity_userMsg',
                
                'activity_nextIsTrue',
                 'activity_ProductPic',
                'activity_nextProductPic'
                ], 'safe'],
        ];
    }

    public function attributeLabels() {

        return [
           /* 'activity_Underway' => '活动是否继续',
            'activity_EndTime' => '结束的时间',*/
            'activity_secretKey' => '反作弊secretKey',
            'activity_secretId' => '反作弊secretId',
            'activity_businessId' => '反作弊businessId',
            
             'activity_MsgAppkey' => '消息Appkey',
             'activity_MsgAppsecret' => '消息Appsecret',
            'activity_userMsg'=>'用户发送的信息',
            'activity_nextIsTrue'=>'显示下期产品预告',
             'activity_ProductPic'=>'本期图片',
            'activity_nextProductPic'=>'下期图片'
        ];
    }
     /**
     *活动正在进行
    */
    const VAL_yes='yes';
    /**
     * 活动结束了
    */
    const VAL_END='end';
    
    /**
     * 记录活动是否正在进行的ID
    */
    const ID_Underway='1';
    /**
     * 记录活动结束的时间
    */
    const ID_EndTime='2';
    
    
     /**
      * 获取配置参数
     */
    public static function getConfig(){
        $cacheObj=Yii::$app->cache;
        $cache=$cacheObj->get('getDun');
        if($cache){
            return $cache;
        }
        $model=self::model();
        $val=[
            'secretKey'=>$model->activity_secretKey,
            'secretId'=>$model->activity_secretId,
            'businessId'=>$model->activity_businessId,
            
            'MsgAppkey'=>$model->activity_MsgAppkey,
            'MsgAppsecret'=>$model->activity_MsgAppsecret,
        ];
        $cacheObj->set('getDun', $val);
        return $val;
    }
     
   /**
    * 是否预约和图片
    */
    public static function getYuyue(){
        $cache=Yii::$app->cache;
        $key='getYuyueact';
        $caval=$cache->get($key);
        if($caval){
            return $caval;
        }
        $caval=[
            'activity_nextIsTrue'=>self::model()->activity_nextIsTrue,
            'activity_ProductPic'=>self::model()->activity_ProductPic,
             'activity_nextProductPic'=>self::model()->activity_nextProductPic
        ];
        $caval=  json_encode($caval);
        $cache->set($key, $caval,60);
        return $caval;
    }
    
    
}
